home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MYMUD21.ZIP / MMUD21.ZIP / SOURCE / SOURCE.ZIP / CONVERT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-01-21  |  6.5 KB  |  189 lines

  1. Program Convert;
  2.  
  3. Const
  4.  
  5. { Room_Flags: Room types }
  6.       Temple_Room          = $0001;
  7.       Haven_Room           = $0002;
  8.       Shop_Room            = $0004;
  9.  
  10. { Attr_Flags }
  11.       Link_Ok_Flag         = $0001;
  12.       Sticky_Flag          = $0002;
  13.       Teleport_Ok_Flag     = $0004;
  14.       Invisible_Flag       = $0008;
  15.       For_Sale_Flag        = $0010;
  16.       ChOwn_Ok_Flag        = $0020;
  17.  
  18. { System Flags }
  19.       Macro_Flag           = $0001;
  20.  
  21.  
  22.  
  23. Const Gender_Mask        = $0007;      { The low 3 bits of }
  24.       No_Gender          = $0000;
  25.       Neuter_Gender      = $0001;
  26.       Female_Gender      = $0002;
  27.       Male_Gender        = $0003;
  28.  
  29.       O_Temple_Room        = $0010;      { For donations                }
  30.       O_Haven_Room         = $0020;      { No fighting allowed          }
  31.       O_Shop_Room          = $0040;      { To sell and buy old objs.    }
  32.       O_Macro_Flag         = $0080;      { This object can be USED      }
  33.       O_Link_Ok_Flag       = $0100;      { Define an object as LINKABLE }
  34.       O_Stiky_Flag         = $0200;      { Define an object as STIKY    }
  35. {**}  O_Teleport_Ok_Flag   = $0400;      { Everybody can tele to here   }
  36.       O_Invisible_Flag     = $0800;      { To hide long lists of objs.  }
  37.       O_For_Sale_Flag      = $1000;      { Object has no current owner  }
  38.       O_CHOWN_OK_flag      = $2000;      { Can be owned by someone      }
  39.       { Undefined          = $8000; }
  40.  
  41.  
  42.  
  43. Type LongRec    = Record  { filepointer and length of a longtekst }
  44.                     Start   : LongInt;
  45.                     Length  : Word;
  46.                   End;
  47.  
  48. Type  OldRecord  = Record
  49.                     Name     : String;      { Object name              }
  50.                     Password : String[40];  { Password for players     }
  51.                     Key      : String[40];  { Boolean key              }
  52.  
  53.                     Location : Integer;     { Current location         }
  54.                     Contents : Integer;     { Start of contents list   }
  55.                     Exits    : Integer;     { Start of exits list      }
  56.                     Next     : Integer;     { continue list            }
  57.                     Owner    : Integer;     { Recordnumber of owner    }
  58.                     Pennies  : Integer;     { Value/amound of pennies  }
  59.  
  60.                     ObjType  : Byte;     { Thing, room, exit, player, Drone}
  61.                     ObjLevel : Byte;     { Toad,player,builder,wizard,god  }
  62.                     GenFlags : LongInt;
  63.  
  64.                     Desc     : LongRec;  { Pointer to long description }
  65.  
  66.                     Fail     : LongRec;  { Pointer to fail string      }
  67.                     Success  : LongRec;  { Pointer to Success string   }
  68.                     OFail    : LongRec;  { Pointer to fail for others  }
  69.                     OSuccess : LongRec;  { Pointer to succes for others}
  70.  
  71.                   End;
  72.  
  73.      NEWRecord  = Record
  74.                     Name     : String;      { Object name              }
  75.                     Password : String[40];  { Password for players     }
  76.                     Key      : String[40];  { Boolean key              }
  77.  
  78.                     Location : Integer;     { Current location         }
  79.                     Contents : Integer;     { Start of contents list   }
  80.                     Exits    : Integer;     { Start of exits list      }
  81.                     Next     : Integer;     { continue list            }
  82.                     Owner    : Integer;     { Recordnumber of owner    }
  83.                     Pennies  : Integer;     { Value/amound of pennies  }
  84.  
  85.                     ObjType  : Byte;     { Thing, room, exit, player, Drone}
  86.                     ObjLevel : Byte;     { Toad,player,builder,wizard,god  }
  87.                     GenFlags : LongInt;
  88.  
  89.                     Desc     : LongRec;  { Pointer to long description }
  90.  
  91.                     Fail     : LongRec;  { Pointer to fail string      }
  92.                     Success  : LongRec;  { Pointer to Success string   }
  93.                     OFail    : LongRec;  { Pointer to fail for others  }
  94.                     OSuccess : LongRec;  { Pointer to succes for others}
  95.  
  96.                     Macro    : LongRec;  { Pointer to macro            }
  97.  
  98.                     Sex        : Byte;
  99.                     Room_Flags : LongInt;
  100.                     Attr_Flags : LongInt;
  101.  
  102.                     Storage    : Array[0..9] of Integer;
  103.  
  104.                     Filler     : Array[1..83] of Byte;
  105.                   End;
  106.  
  107.  
  108. Function BitSet(L,Flag : LongInt):Boolean;
  109. Begin
  110. BitSet:=(L And Flag)=Flag;
  111. End;
  112.  
  113. Procedure SetBit(Var L : LongInt; Flag : LongInt);
  114. Begin
  115. L:=L Or Flag;
  116. End;
  117.  
  118.  
  119. Procedure CheckRecord(Var Rec : NewRecord);
  120. Var Temp : LongInt;
  121. Begin
  122. With Rec Do
  123.  Begin
  124.  Room_Flags:=0;
  125.  If BitSet(GenFlags,O_Temple_Room) then SetBit(Room_Flags,Temple_Room);
  126.  If BitSet(GenFlags,O_Haven_Room) then SetBit(Room_Flags,Haven_Room);
  127.  If BitSet(GenFlags,O_Shop_Room) then SetBit(Room_Flags,Shop_Room);
  128.  
  129.  Attr_Flags:=0;
  130.  If BitSet(GenFlags,O_Link_Ok_Flag) then SetBit(Attr_Flags,Link_Ok_Flag);
  131.  If BitSet(GenFlags,O_Stiky_Flag) then SetBit(Attr_Flags,Sticky_FLag);
  132.  If BitSet(GenFlags,Teleport_Ok_Flag) then SetBit(Attr_Flags,Teleport_Ok_Flag);
  133.  If BitSet(GenFlags,O_Invisible_Flag) then SetBit(Attr_Flags,Invisible_Flag);
  134.  If BitSet(GenFlags,O_For_Sale_Flag) then SetBit(Attr_Flags,For_Sale_Flag);
  135.  If BitSet(GenFlags,O_Chown_ok_Flag) then SetBit(Attr_Flags,Chown_Ok_Flag);
  136.  
  137.  Sex:=GenFlags And Gender_Mask;
  138.  
  139.  Temp:=0;
  140.  If BitSet(GenFlags,O_Macro_Flag) then SetBit(Temp,Macro_Flag);
  141.  GenFlags:=Temp;
  142.  End;
  143.  
  144. End;
  145.  
  146.  
  147. Var Inp : File of OldRecord;
  148.     Out : File of NewRecord;
  149.  
  150.     IRec: OldRecord;
  151.     ORec: NewRecord;
  152.  
  153. Begin
  154. Assign(Inp,ParamStr(1)+'.IDX');
  155. Rename(Inp,ParamStr(1)+'.OLD');
  156. Reset(Inp);
  157.  
  158. Assign(Out,ParamStr(1)+'.IDX');
  159. Rewrite(Out);
  160.  
  161. While Not Eof(Inp) Do
  162.  Begin
  163.  Read(Inp,IRec);
  164.  FillChar(ORec,SizeOf(ORec),#00);
  165.  ORec.Name       := IRec.Name;
  166.  ORec.Password   := IRec.Password;
  167.  ORec.Key        := IRec.Key;
  168.  ORec.Location   := IRec.Location;
  169.  ORec.Contents   := IRec.Contents;
  170.  ORec.Exits      := IRec.Exits;
  171.  ORec.Next       := IRec.Next;
  172.  ORec.Owner      := IRec.Owner;
  173.  ORec.Pennies    := IRec.Pennies;
  174.  ORec.ObjType    := IRec.ObjType;
  175.  ORec.ObjLevel   := IRec.ObjLevel;
  176.  ORec.GenFlags   := IRec.GenFlags;
  177.  ORec.Desc       := IRec.Desc;
  178.  ORec.Fail       := IRec.Fail;
  179.  ORec.Success    := IRec.Success;
  180.  ORec.OFail      := IRec.OFail;
  181.  ORec.OSuccess   := IRec.OSuccess;
  182.  
  183.  CheckRecord(ORec);
  184.  Write(Out,ORec);
  185.  End;
  186. Close(Inp);
  187. Close(Out);
  188. End.
  189.